# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Dany Martineau <dany.luc.martineau@gmail.com>

pkgname=drumstick
pkgver=2.8.1
pkgrel=1
pkgdesc="MIDI libraries for Qt5/C++"
arch=(loong64 x86_64)
url="https://drumstick.sourceforge.io/"
license=(GPL2)
depends=(
  gcc-libs
  glibc
  hicolor-icon-theme
  qt6-base
  qt6-5compat
)
makedepends=(
  alsa-lib
  cmake
  doxygen
  docbook-xsl
  fluidsynth
  graphviz
  libpulse
  qt6-tools
  sonivox
)
provides=(
  libdrumstick-alsa.so
  libdrumstick-file.so
  libdrumstick-rt.so
  libdrumstick-widgets.so
)
source=(https://downloads.sourceforge.net/$pkgname/$pkgver/$pkgname-$pkgver.tar.bz2)
sha512sums=('69a507150466b23716a798b74618141c9f52a4a8be6ff6e70a3a482c5e83a3f8a5704d10b0ed2613f34a7ee129a755c46ffdab10949b0b449574baaf9cd10ebb')
b2sums=('15c2ce34380fc82e259f4a17ae6ca6646e140c994f59164597ca0b72f5bd6afe004ead7835715b4f35a1ee1c9872388805728d57880cec1877de344d918b89c7')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  # some tests fail due to insufficient system privileges, hence only run those
  # that make sense in the build environment
  # https://sourceforge.net/p/drumstick/bugs/24/
  make test -C build/tests/fileTest1
  make test -C build/tests/fileTest2
}

package() {
  depends+=(
    alsa-lib libasound.so
    fluidsynth libfluidsynth.so
    libpulse libpulse.so libpulse-simple.so
    sonivox libsonivox.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/{AUTHORS,ChangeLog,NEWS,readme.md,TODO} -t "$pkgdir/usr/share/doc/$pkgname/"
}
